package com.tanhua.server.controller;


import com.tanhua.domain.db.User;
import com.tanhua.server.service.SoulService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/testSoul")
@Slf4j
public class SoulController {

    @Autowired
    private SoulService soulService;

    /**
     * 接口名称：测灵魂-问卷列表（学生实战）
     * 接口路径：GET/testSoul
     */
    @GetMapping
    public ResponseEntity<Object> testSoul() {
        log.info("测灵魂-问卷列表");
        return soulService.testSoul();
    }

    /**
     * 接口名称：测灵魂-提交问卷（学生实战）
     * 接口路径：POST/testSoul
     */
    @PostMapping
    public ResponseEntity<Object> submitSoul(@RequestBody Map<String, Object> map) {
        log.info("测灵魂-提交问卷");
        List<Map<String, String>> answers = (List<Map<String, String>>) map.get("answers");
        return soulService.submitSoul(answers);
    }

    /**
     * 接口名称：测灵魂-查看结果（学生实战）
     * 接口路径：GET/testSoul/report/:id
     */
    @GetMapping("/report/{id}")
    public ResponseEntity<Object> report(@PathVariable String id) {
        log.info("测灵魂-查看结果");
        return soulService.report(id);
    }
}
